import {defineStore} from "pinia";
import {reqHospitalDepartment, reqHospitalDetail} from "@/api/hospital";
import {ref} from "vue";
import { HospitalDepartment, HospitalDetail} from "@/api/hospital/type.ts";

const useDetailStore = defineStore('Detail', () => {

  const hospitalDetail = ref<HospitalDetail>()

  const hospitalDepartment = ref<HospitalDepartment[]>()
  const getHospital = async (hoscode:string)=>{
    const result =  await reqHospitalDetail(hoscode)
    console.log(result)
    hospitalDetail.value = result.data
  }
  const getDepartment = async (hoscode:string)=>{
    const result =  await reqHospitalDepartment(hoscode)
    console.log(result)
    hospitalDepartment.value = result.data
  }

  return {
    hospitalDetail,
    getHospital,
    hospitalDepartment,
    getDepartment

  }
})

export default useDetailStore
